<?php
    header('Access-Control-Allow-Origin:*');
    header("content-type:text/html;charset=utf-8");
    // echo '<pre>';
    // print_r($_POST);
    if($_POST){
        $row_name = $_POST['name'];
        $row_content = $_POST['content'];
        $row_version = $_POST['version'];
        $row_ctime = $_POST['c_time'];
        $row_mtime = $_POST['m_time'];
        $db_con = mysqli_connect('localhost','root','');
        if($db_con){
            $result = mysqli_query($db_con,'set names utf8');
            $result = mysqli_query($db_con,'use sx_control');
            $sql = "insert into project values(default , '$row_name','$row_content','$row_version','$row_ctime','$row_mtime')";
            $result = mysqli_query($db_con,$sql);
            $result = mysqli_query($db_con,'select last_insert_id()');
            $last = mysqli_fetch_row($result);
            $last_id = $last[0];
            // print_r ($last_id);
            $new_table = 'controller'.$last_id;
            $sql = "create table $new_table select * from controller1 where 1=2";
            $result = mysqli_query($db_con,$sql);
            mysqli_close($db_con);
        } else {
            die ('数据库连接失败');
        }
    }
?>